from PySide6.QtWidgets import QWidget, QVBoxLayout, QPushButton

from gui.widgets_map import open_window


class TitleBoard(QWidget):
    def __init__(self):
        super().__init__()

        self.setWindowTitle('打造超级战士模拟器')

        self.setGeometry(300, 300, 309, 500)

        layout = QVBoxLayout()
        layout.addStretch(1)
        btn_new_game = QPushButton('新游戏', self)
        btn_new_game.clicked.connect(self.create_game_window)
        layout.addWidget(btn_new_game)
        btn_load_game = QPushButton('载入存档', self)
        layout.addWidget(btn_load_game)
        layout.addStretch(1)

        self.setLayout(layout)

    def create_game_window(self):
        open_window('new_game')
        self.close()

    def closeEvent(self, event):
        super().closeEvent(event)
